package com.xucan.equalsx;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Person {
    private String name;
    private String age;
    private String sex;

    public Person(String name) {
        this.name = name;
    }

    public static void main(String[] args) {
        Person p1 = new Person("xucan");
        Person p2 = new Person("xucan");
        System.out.println(p1.hashCode());
        System.out.println(p2.hashCode());
        System.out.println(p1.equals(p2));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(name, person.name);
    }


}
